'use strict';
var content;
function mycall(data)
{
    content = data;
}

function GfCmsCtrl($scope,$http,$location){
    $scope.selected = "";
    $scope.select = function(product)
    {
       $scope.selected = product.description;
    };
    $scope.deselect = function()
    {
        $scope.selected="";
    };
    $scope.publish = function(value){
        var rows = $("#mytable").jqGrid('getGridParam','selarrrow');
        if(!rows.length)
        {
            rows="Please select rows";
        }
        //alert(rows);
        var items= [];
        var data={};
        for (var i=0;i<rows.length;i++)
        {
            var item = {};
            item["id"] = rows[i];
            item["published"] = value;
            items.push(item);
        }
        data["items"]= items;

        $http.get('/admin/login').error(function(){alert("login failed");});
        $http.post('/admin/product/publish',data).
            success(function(){$('#mytable').trigger("reloadGrid");}).
            error(function(res){alert(res.error);});
    }
    $scope.addclass = function(){
   
    }
    $scope.search = function(){
        $("#mytable").jqGrid('searchGrid',
                            {sopt:['cn','bw','eq','ne','lt','gt','ew']}
                           );
    }
    $http.get('products/productt.json').success(function(data){
        $scope.products = data;
        $scope.orderProp = '_id';
    });
    $http.get('products/category.json').success(function(data){
        $scope.categorys = data; 
        $scope.tree = data;
    })

}
GfCmsCtrl.$inject = ['$scope', '$http','$location'];
